package leetcode.math;

public class BaseSeven504 {
    class Solution {
        public String convertToBase7(int num) {
            if (num == 0) {
                return "0";
            }
            String ans = new String();
            int temp = Math.abs(num);
            while (temp != 0) {
                int a = temp / 10;
                int b = temp % 10;
                ans = b + "" + ans;
                temp = a;
            }
            if (num < 0) {
                ans = "-" + ans;
            }
            return ans;
        }
    }
}
